<template>
	<view class="user">
		<view class="top">
			 <image src="../../static/images/history.png" mode=""></image>
			 <view class="his">
			 	浏览历史
			 </view>
		</view>
		<view class="content" >
			<view  class="row" v-for="item in listArr">
		    <newsBox :item="item" @click.native="goDetail(item)"></newsBox>
		</view>
		</view>
		
		<view class="nohistory" v-if="!listArr.length">
			<image src="../../static/images/nohis.png" mode="widthFix"></image>
			<view class="text">暂无浏览记录</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				listArr:[]
			};
		},
		onShow(){
			this.getUserData()
		},
		methods:{
			goDetail(item){
				uni.navigateTo({
					url:`/pages/detail/detail?cid=${item.classid}&id=${item.id}`
				})
			},
			getUserData(){
				uni.showLoading({
					mask:true,
					title:'加载中'
				})
				let hisArr=uni.getStorageSync("historyArr") || []
				this.listArr=hisArr
				uni.hideLoading()
				// console.log(this.listArr)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.user{
		.top{
			height: 400rpx;
			padding: 20rpx 0;
			background-color: #F8F8F8;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			image{
				width: 200rpx;
				height: 200rpx;
			}
			.his{
				margin-top: 10rpx;
				font-size: 34rpx;
			}
		}
		.content{
			   padding: 20rpx;
			   .row{
			   		   padding:15rpx 0rpx;
					   border-bottom: 1rpx dashed #efefef;
			   }
		 }
		 .nohistory{
		 	display: flex;
		 	flex-direction: column;
		 	justify-content: center;
		 	align-items: center;
		 	image{
		 		width: 450rpx;
		 	}
		 	.text{
		 		font-size: 26rpx;
		 		color:#888;
		 	}
		 }
	}

</style>
